import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:im_base/public/tim/components/conversation/classify_conversation/end_widget/view.dart';
import 'package:im_base/public/tim/components/conversation/classify_conversation/going_on_widget/view.dart';

import 'logic.dart';

///医生端对会话进行分类
class ClassifyConversationWidget extends StatefulWidget {
  final logic = Get.put(ClassifyConversationLogic());
  final Function(String, String, bool) itemClick;

  ClassifyConversationWidget({required this.itemClick});

  @override
  State<ClassifyConversationWidget> createState() =>
      ClassifyConversationState();
}

class ClassifyConversationState extends State<ClassifyConversationWidget>
    with TickerProviderStateMixin {
  @override
  void initState() {
    widget.logic.state.tabBarController = TabController(length: 2, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        TabBar(
          tabs: [
            Container(
              height: 45,
              width: 80,
              alignment: Alignment.center,
              child: Text('进行中'),
            ),
            Container(
                height: 45,
                width: 80,
                alignment: Alignment.center,
                child: Text('已结束'))
          ],
          controller: widget.logic.state.tabBarController,
          indicatorColor: Colors.blue,
          labelColor: Colors.blue,
          indicatorSize: TabBarIndicatorSize.label,
          unselectedLabelColor: Colors.grey[600],
          labelStyle: TextStyle(fontSize: 16),
          onTap: (index) =>
              widget.logic.state.tabBarController!.animateTo(index),
        ),
        Container(
          height: 1,
          decoration: BoxDecoration(
              border: Border(bottom: BorderSide(color: Colors.grey[300]!))),
        ),
        Expanded(
            child: TabBarView(
              children: [
                GoingOnWidgetPage(widget.itemClick),
                EndInquiryPage(widget.itemClick)
              ],
              controller: widget.logic.state.tabBarController,
            ))
      ],
    );
  }
}
